{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda3_5_0_0\\lib\\site-packages\\h5py\\__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n",
      "  from ._conv import register_converters as _register_converters\n"
     ]
    }
   ],
   "source": [
    "import tensorflow as tf\n",
    "import numpy as np\n",
    "from tensorflow.python.framework import ops\n",
    "import os\n",
    "ops.reset_default_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "sess = tf.Session()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.summary.writer.writer.FileWriter at 0x14417d46c88>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[[ 1  2  3  4  5]\n",
      "  [11 12 13 14 15]\n",
      "  [21 22 23 24 25]]\n",
      "\n",
      " [[ 2  3  4  5  6]\n",
      "  [12 13 14 15 16]\n",
      "  [22 23 24 25 26]]]\n"
     ]
    }
   ],
   "source": [
    "#创建numpy数组3x5\n",
    "np_array = np.array([[1,2,3,4,5],\n",
    "                     [11,12,13,14,15],\n",
    "                    [21,22,23,24,25]])\n",
    "np_vals = np.array([np_array,np_array+1])\n",
    "print(np_vals)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "input_data = tf.placeholder(shape=[3,None],dtype=tf.float32)\n",
    "m1 = tf.constant([[1.0],[0.0],[9.0],[3.0],[5.0]])\n",
    "m2 = tf.constant([[3.0]])\n",
    "a = tf.constant([[2.0]])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[ 197.]\n",
      " [ 737.]\n",
      " [1277.]]\n",
      "[[ 251.]\n",
      " [ 791.]\n",
      " [1331.]]\n"
     ]
    }
   ],
   "source": [
    "o1 = tf.matmul(input_data,m1)#3x5 * 5x1 ==>3x1\n",
    "o2 = tf.matmul(o1,m2)#3x1 * 1x1 ==>3x1\n",
    "o3 = tf.add(o2,a)\n",
    "\n",
    "for i in np_vals:\n",
    "    print(sess.run(o3,feed_dict={input_data:i}))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<tensorflow.python.summary.writer.writer.FileWriter at 0x1441dd67be0>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "tf.summary.FileWriter(\"./tmp/logs\",sess.graph)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
